<extend name="Public/base" />
<block name="body">
    <div class="main-title" style="padding-bottom: 0px;">
		<h2>apps</h2>
	</div>
	<div class="tab-wrap">
		<div class="tab-content">
			<div class="tab-pane in">
				<form action="{:U('User/apps')}" enctype="application/x-www-form-urlencoded" method="POST" class="form-horizontal auth-form">
						<dl class="checkmod">
							<dt class="hd">
								<label class="checkbox"><input class="auth_rules rules_all" type="checkbox">全选</label>
							</dt>
							<dd class="bd" style="overflow: hidden;">
								<volist name="apps" id="app" >
                                    <div class="rule_check" style="width: 25%;float: left;">
                                        <div>
                                            <label class="checkbox" title='{$app.desc}'>
                                           <input class="auth_rules rules_row" type="checkbox" name="apps[]" value="{$app.id}"/>{$app.name}
                                            </label>
                                        </div>
				                    </div>
								</volist>
							</dd>
						</dl>
			        <input type="hidden" name="uid" value="{$uid}" />
                    <button type="submit" class="btn submit-btn ajax-post" target-form="auth-form">确 定</button>
                    <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
			    </form>
			</div>

		</div>
	</div>

</block>
<block name="script">
<script type="text/javascript" src="__STATIC__/qtip/jquery.qtip.min.js"></script>
<link rel="stylesheet" type="text/css" href="__STATIC__/qtip/jquery.qtip.min.css" media="all">
<script type="text/javascript" charset="utf-8">
    +function($){
        var rules = [{$app_ids}];
        $('.auth_rules').each(function(){
            if( $.inArray( parseInt(this.value,10),rules )>-1 ){
                $(this).prop('checked',true);
            }
            if(this.value==''){
                $(this).closest('span').remove();
            }
        });

        //全选节点
        $('.rules_all').on('change',function(){
            $(this).closest('dl').find('dd').find('input').prop('checked',this.checked);
        });
        $('.rules_row').on('change',function(){
            $(this).closest('.rule_check').find('.child_row').find('input').prop('checked',this.checked);
        });

        $('.checkbox').each(function(){
            $(this).qtip({
                content: {
                    text: $(this).attr('title'),
                    title: $(this).text()
                },
                position: {
                    my: 'bottom center',
                    at: 'top center',
                    target: $(this)
                },
                style: {
                    classes: 'qtip-dark',
                    tip: {
                        corner: true,
                        mimic: false,
                        width: 10,
                        height: 10
                    }
                }
            });
        });

    }(jQuery);
    highlight_subnav('{:U('User/index')}');
</script>
</block>
